﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using HYSoft.Common;
using HYSoft.Model;
using HYSoft.DALFactory;
using HYSoft.IDAL;

namespace HYSoft.BLL
{
    /// <summary>
    /// monitor_info
    /// </summary>
    public partial class monitor_info
    {
        private readonly Imonitor_info dal = DataAccess.Createmonitor_info();
        public monitor_info()
        { }
        #region  BasicMethod
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int index, string m_area_name, string m_area_id, string addr, string type, string level, int population, int count, string contact_name1, string contact_mobile1, string contact_name2, string contact_mobile2, string contact_name3, string contact_mobile3, string upunit1, string upcontact_name1, string upcontact_mobile1, string upunit2, string upcontact_name2, string upcontact_mobile2, int intvalue1, int intvalue2, int intvalue3, string charvalue1, string charvalue2, string charvalue3, int user_index, string coordinates_x, string coordinates_y)
        {
            return dal.Exists(index, m_area_name, m_area_id, addr, type, level, population, count, contact_name1, contact_mobile1, contact_name2, contact_mobile2, contact_name3, contact_mobile3, upunit1, upcontact_name1, upcontact_mobile1, upunit2, upcontact_name2, upcontact_mobile2, intvalue1, intvalue2, intvalue3, charvalue1, charvalue2, charvalue3, user_index, coordinates_x, coordinates_y);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(HYSoft.Model.monitor_info model)
        {
            return dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(HYSoft.Model.monitor_info model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int index, string m_area_name, string m_area_id, string addr, string type, string level, int population, int count, string contact_name1, string contact_mobile1, string contact_name2, string contact_mobile2, string contact_name3, string contact_mobile3, string upunit1, string upcontact_name1, string upcontact_mobile1, string upunit2, string upcontact_name2, string upcontact_mobile2, int intvalue1, int intvalue2, int intvalue3, string charvalue1, string charvalue2, string charvalue3, int user_index, string coordinates_x, string coordinates_y)
        {

            return dal.Delete(index, m_area_name, m_area_id, addr, type, level, population, count, contact_name1, contact_mobile1, contact_name2, contact_mobile2, contact_name3, contact_mobile3, upunit1, upcontact_name1, upcontact_mobile1, upunit2, upcontact_name2, upcontact_mobile2, intvalue1, intvalue2, intvalue3, charvalue1, charvalue2, charvalue3, user_index, coordinates_x, coordinates_y);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public HYSoft.Model.monitor_info GetModel(int index, string m_area_name, string m_area_id, string addr, string type, string level, int population, int count, string contact_name1, string contact_mobile1, string contact_name2, string contact_mobile2, string contact_name3, string contact_mobile3, string upunit1, string upcontact_name1, string upcontact_mobile1, string upunit2, string upcontact_name2, string upcontact_mobile2, int intvalue1, int intvalue2, int intvalue3, string charvalue1, string charvalue2, string charvalue3, int user_index, string coordinates_x, string coordinates_y)
        {

            return dal.GetModel(index, m_area_name, m_area_id, addr, type, level, population, count, contact_name1, contact_mobile1, contact_name2, contact_mobile2, contact_name3, contact_mobile3, upunit1, upcontact_name1, upcontact_mobile1, upunit2, upcontact_name2, upcontact_mobile2, intvalue1, intvalue2, intvalue3, charvalue1, charvalue2, charvalue3, user_index, coordinates_x, coordinates_y);
        }

        /// <summary>
        /// 得到一个对象实体，从缓存中
        /// </summary>
        public HYSoft.Model.monitor_info GetModelByCache(int index, string m_area_name, string m_area_id, string addr, string type, string level, int population, int count, string contact_name1, string contact_mobile1, string contact_name2, string contact_mobile2, string contact_name3, string contact_mobile3, string upunit1, string upcontact_name1, string upcontact_mobile1, string upunit2, string upcontact_name2, string upcontact_mobile2, int intvalue1, int intvalue2, int intvalue3, string charvalue1, string charvalue2, string charvalue3, int user_index, string coordinates_x, string coordinates_y)
        {

            string CacheKey = "monitor_infoModel-" + index + m_area_name + m_area_id + addr + type + level + population + count + contact_name1 + contact_mobile1 + contact_name2 + contact_mobile2 + contact_name3 + contact_mobile3 + upunit1 + upcontact_name1 + upcontact_mobile1 + upunit2 + upcontact_name2 + upcontact_mobile2 + intvalue1 + intvalue2 + intvalue3 + charvalue1 + charvalue2 + charvalue3 + user_index + coordinates_x + coordinates_y;
            object objModel = HYSoft.Common.DataCache.GetCache(CacheKey);
            if (objModel == null)
            {
                try
                {
                    objModel = dal.GetModel(index, m_area_name, m_area_id, addr, type, level, population, count, contact_name1, contact_mobile1, contact_name2, contact_mobile2, contact_name3, contact_mobile3, upunit1, upcontact_name1, upcontact_mobile1, upunit2, upcontact_name2, upcontact_mobile2, intvalue1, intvalue2, intvalue3, charvalue1, charvalue2, charvalue3, user_index, coordinates_x, coordinates_y);
                    if (objModel != null)
                    {
                        int ModelCache = HYSoft.Common.ConfigHelper.GetConfigInt("ModelCache");
                        HYSoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
                    }
                }
                catch { }
            }
            return (HYSoft.Model.monitor_info)objModel;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return dal.GetList(Top, strWhere, filedOrder);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<HYSoft.Model.monitor_info> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<HYSoft.Model.monitor_info> DataTableToList(DataTable dt)
        {
            List<HYSoft.Model.monitor_info> modelList = new List<HYSoft.Model.monitor_info>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                HYSoft.Model.monitor_info model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = dal.DataRowToModel(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public int GetRecordCount(string strWhere)
        {
            return dal.GetRecordCount(strWhere);
        }
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            return dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
        }
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //return dal.GetList(PageSize,PageIndex,strWhere);
        //}

        #endregion  BasicMethod
        #region  ExtensionMethod

        #endregion  ExtensionMethod
    }
}
